from .connect_mysql import Connect

class Detail(Connect):

    def detail(self,ID):

        detail_sql = 'select * from company where id = %s'

        self.cursor.execute(detail_sql,(ID,))

        result = self.cursor.fetchone()

        # print(result['update_time'])
        if result:

            result.update({"update_time": result['update_time'].__str__()})
            result.update({"regedate": result['regedate'].__str__()})

        print(result)
        return result

    def openid_verify(self,openid,ID):

        result_info = self.detail(ID)
        
        openid_sql = 'select * from openid where openid=%s and pay=1'

        self.cursor.execute(openid_sql,(openid,))

        result = self.cursor.fetchone()

        if result:

            return{
                'status':'1',
                'errorCode':None,
                'errorMsg':None,
                'resultBody':result_info }

        else:
            result_info['phone'] = result_info['phone'][0:3] +'****'+result_info['phone'][-4:]
            return{
               'status':'1',
                'errorCode':None,
                'errorMsg':None,
                'resultBody':result_info
            }
            
            


